﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace WindowsGame1
{
    public class AlienManager
    {
        public List<Alien> aliens = new List<Alien>();

        public List<AlienEvent> events = new List<AlienEvent>();

        Random rnd = new Random();

        float last = 0;
        float current = 0;
        //float time = 0;

        public void Update(Timer t)
        {
            last = current;
            current += t.Delta;

            for (int i = 0; i < events.Count; i++)
            {
                AlienEvent ae = events[i];
                bool cont = ae.Pool(last, current);
                if (ae.done)
                    events.RemoveAt(i--);
            }

            for (int i = 0; i < aliens.Count; i++)
            {
                Alien alien = aliens[i];
                alien.Update(t);
                if (alien.IsAlive() == false)
                {
                    aliens.RemoveAt(i--);
                }
            }
        }

        public void Draw(SpriteBatch sb)
        {
            foreach (Alien alien in aliens)
                alien.Draw(sb);
        }

        public AlienManager()
        {
            Level1 l = new Level1();
            l.Setup(this);
        }


    }
}
